package com.gyy;

import com.gyy.Alarm.ThermometryAlarm;
import com.gyy.GeneralFunction.Login;
import com.gyy.GeneralFunction.Logout;
import com.gyy.sdk.HCNetSDK;

import static com.gyy.constant.HkConstant.LOG_LIST;

/**
 * @author GuoMingDe
 * @description 主程序启动类
 * @date 2021-09-28 16:28
 */
public class Application {

    public static HCNetSDK hCNetSDK = HCNetSDK.INSTANCE;

    /**
     * 用户句柄
     */
    public static int userId = -1;

    public static Login login = new Login();
    public static Logout logout = new Logout();
    public static ThermometryAlarm thermometryAlarm = new ThermometryAlarm();
    public static int num = 0;


    /**
     * 主程序
     *
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception {

        // 初始化SDK
        hCNetSDK.NET_DVR_Init();

        // 配置日志文件
        hCNetSDK.NET_DVR_SetLogToFile(3, LOG_LIST, true);

        // 登陆
        userId = login.getUserID("192.168.137.64", (short) 8000, "admin", "gyyjy@123");

        // 报警布防
        thermometryAlarm.SetAlarm(userId);

        while (num++ < 100000) {
            System.out.println("-------------------------------------- ping");
            Thread.sleep(1000 * 60 * 10);
        }

        // 登出，优雅关闭
        logout.Logout(thermometryAlarm, userId);

    }
}
